package com.qf.sy2103.ssm.service.impl;


import com.qf.sy2103.ssm.dao.UserDao;
import com.qf.sy2103.ssm.entity.User;
import com.qf.sy2103.ssm.service.UserServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLException;

@Service
public class UserServiceImpl implements UserServcie {
    @Autowired
    private UserDao userDao;
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int regist(User user) {
        int insert = userDao.insert(user);
        return insert;
    }
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public User login(String name, String password) {
        User user = userDao.selectnamepassword(name, password);
        return user;
    }
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public User sname(String name) {
        User u = userDao.selectname(name);
        return u;
    }
}
